import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { shopProductSellListData } from '/@/api/shop/sell/shopProductSell';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('促销选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  schemas: [
    {
      label: t('活动标题'),
      field: 'ctitle',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('活动标题'),
    dataIndex: 'ctitle',
    key: 'a.ctitle',
    sorter: true,
    width: 230,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('活动简介'),
    dataIndex: 'simpleContent',
    key: 'a.simple_content',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('活动详情'),
    dataIndex: 'content',
    key: 'a.content',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('缩略图地址'),
    dataIndex: 'picUrl',
    key: 'a.pic_url',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('活动开始'),
    dataIndex: 'beginDate',
    key: 'a.begin_date',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('活动结束'),
    dataIndex: 'endDate',
    key: 'a.end_date',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('促销包名称'),
    dataIndex: 'abbName',
    key: 'a.abb_name',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('主产品'),
    dataIndex: 'basInv.cinvname',
    key: 'a.main_inv',
    sorter: true,
    width: 200,
    align: 'left',
  },
  {
    title: t('单价'),
    dataIndex: 'fprice',
    key: 'a.fprice',
    sorter: true,
    width: 130,
    align: 'right',
  },
  {
    title: t('发布状态'),
    dataIndex: 'fbStatus',
    key: 'a.fb_status',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'shop_fb_status',
  },
  {
    title: t('是否关闭'),
    dataIndex: 'bclose',
    key: 'a.bclose',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'sys_yes_no',
  },
  {
    title: t('关闭日期'),
    dataIndex: 'closeDate',
    key: 'a.close_date',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('起订量'),
    dataIndex: 'moq',
    key: 'a.moq',
    sorter: true,
    width: 130,
    align: 'center',
  },
];

const tableProps: BasicTableProps = {
  api: shopProductSellListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    params['ope'] = '1';
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'id',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'id',
  itemName: 'abbName',
};
